<template>
	<view>
		<image src="../../static/bghome.jpg" class="bgImg"></image>
		<text class="all-test">全部测试</text>
		<view class="home">
			<view class="test-item" v-for="(item,index) in questionList" :key='index'>
				<view class="test-item-img">
					<image src="../../static/1.png"></image>
				</view>
				<text>{{item.typename}}</text>
				<button class="mailto" @click="joinTest(item)">参与测试</button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
	} from 'vuex'
	export default {
		data() {
			return {
				questionList: [],
			}
		},
		created() {
			this.getQuestionList()
		},

		computed: { ...mapState(['userinfo'])
		},
		methods: {
			getQuestionList() {
				this.$request({
					method: 'GET',
					url: 'occupation/getQuestionList/',
					header: {
						'token': this.userinfo.token
					},
				}).then(res => {
					this.questionList = res.data
				})
			},
			joinTest(introduce) {
				uni.navigateTo({
					url: '../include/include',
					success: (res) => {
						res.eventChannel.emit('afferentintroduce', {
							data: introduce
						})
					}
				})
			}
		}
	}
</script>

<style>
	.bgImg {
		position: absolute;
		z-index: 0;
		width: 100%;
		height: 100%;
	}

	.home {
		position: absolute;
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: space-evenly;
		top: 80px;
	}

	.all-test {
		position: relative;
		top: 60px;
		left: 15px;
		color: #FFFFFF;
	}

	.test-item {
		display: flex;
		flex-direction: column;
		text-align: center;
		margin-top: 20px;
		width: 150px;
		height: 150px;
		background-color: #ffffff;
		border-radius: 20px;
		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
	}

	.test-item-img image {
		z-index: 1;
		width: 60px;
		height: 60px;
		margin: auto;
		margin-top: 10px;

	}

	.test-item text {
		margin-top: 5px;
		font-size: 14px;
		color: #000000;
		/* 超过单行，显示三个... */
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}


	.mailto {
		height: 25px;
		line-height: 25px;
		width: 100px;
		font-size: 16px;
		margin-top: 10px;
		background-color: #7ac1cd;
		color: #FFFFFF;
	}
</style>
